package go84;

import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;

import com.motorola.iden.lcdui.ExternalDisplayCanvas;

class ExCanvas extends ExternalDisplayCanvas {
	private Go84 go84class;
	//the Satelite drawing 
	int[] sat = { 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1,
			0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1,
			0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0,
			0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1,
			0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1 };
	// the size of the drawing
	int satHeight = 10;
	int satWidth = 10;

	//change 1,0 to white/black
	public ExCanvas(Go84 go84class) {
		this.go84class = go84class;
		for (int i = 0; i < 100; i++) {
			sat[i] *= 0xffffff;
		}
	}

	private String hebString(String str) {
		String strTemp = "";
		String strDisp = "";
		for (int i = str.length() - 1; i >= 0; i--) {
			if (str.charAt(i) > 1400) {
				strDisp = strDisp + strTemp + str.charAt(i);
				strTemp = "";
			} else {
				strTemp = str.charAt(i) + strTemp;
			}
		}
		strDisp = strDisp + strTemp;
		return strDisp;
	}

	protected void keyPressed(int keyCode) {
		/*int temp = go84class.getNavInd();
		//int size = go84class.getRoute().size();
		int size=0;
		if (keyCode == -52) { // vol up
			temp++;
			if (temp >= size)
				temp = -1;
		} else if (keyCode == -51) { // vol up
			temp--;
			if (temp < -1)
				temp = size - 1;
		}
//		go84class.navToPos(temp);
*/	}

	protected void paint(Graphics g) {
		String[] extString = go84class.getExtStrings();
		Font f = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN,
				Font.SIZE_SMALL);
		g.setFont(f);
		g.setColor(0xffffff);
		g.fillRect(0, 0, getWidth(), getHeight());
		g.setColor(0x000000);
		g.drawString(hebString(extString[0]), 0, 0, Graphics.TOP
				| Graphics.LEFT);
		g.drawString(extString[1], getWidth(),
				(getHeight() - f.getHeight()) / 2, Graphics.TOP
						| Graphics.RIGHT);
		g.drawString(extString[2], getWidth(), getHeight(), Graphics.BOTTOM
				| Graphics.RIGHT);
		g.drawString("" + go84class.getSats(), getWidth() - satWidth - 1, 0,
				Graphics.TOP | Graphics.RIGHT);
		g.drawRGB(sat, 0, satWidth, getWidth() - satWidth, 0, satWidth,
				satHeight, false);
	}
}
